package com.wc.alorithm_blue_bridge._二分.Q1264;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

/**
 * @Author congege
 * @Description 排个序
 * https://www.lanqiao.cn/problems/1264/learning/?page=2&first_category_id=1&sort=students_count&second_category_id=8
 * @Date Created in 2023/11/7-10:21
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n + 1];

        /**
         * map 为了快速找到之前a[i]的位置
         */
        HashMap<Integer, Integer> map = new HashMap<>();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            map.put(a[i], i);
        }

        for (int i = 0; i < m; i++) {
            set.add(sc.nextInt());
        }
        /**
         * 记录每一个可以移动的位置
         */
        int[] p = new int[set.size()];
        int idx = 0;
        for (int num : set) {
            p[idx++] = num;
        }
        Arrays.sort(a);
        Arrays.sort(p);
        Main main = new Main();
        for (int i = 1; i <= n; i++) {
            int curIdx = i;
            int preIdx = map.get(a[curIdx]);
            if (!main.isMatch(curIdx, preIdx, p)) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

    public boolean isMatch(int curIdx, int preIdx, int[] p) {
        /**
         * 如果之前和现在位置一样说明不需要移动
         */
        if (curIdx == preIdx) {
            return true;
        }
        /**
         * 调整位置为了下面能统一
         */
        if (curIdx > preIdx) {
            return isMatch(preIdx, curIdx, p);
        }
        /**
         * 先找到前面位置移动
         */
        int sufIdx = quickSearch(curIdx, p);
        if (sufIdx == -1) {
            return false;
        }
        /**
         * 找到后面最后一个位置，如果有就说明正确
         */
        int lenIdx = sufIdx - curIdx + preIdx - 1;
        if (lenIdx > p.length - 1) {
            return false;
        }
        return p[lenIdx] == preIdx - 1;
    }

    public int quickSearch(int val, int[] array) {
        int left = 0;
        int right = array.length - 1;
        int mid;
        while (left <= right) {
            mid = left + (right - left) / 2;
            if (array[mid] == val) {
                return mid;
            } else if (array[mid] > val) {
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        return -1;
    }

    static class Input {
        private StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return (int) in.nval;
        }
    }
}
